package com.automation.demo.testNG;



import java.net.URL;
import java.util.concurrent.TimeUnit;

import org.testng.Assert;
import org.testng.annotations.*;

import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertFalse;
import static org.testng.AssertJUnit.assertTrue;


import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

/**
 * @author David
 *
 */

public class PSLTestNG extends PSLBase {
	
	private String name;
	
	private String password;
	
	@BeforeMethod
	@Parameters({"name", "password"})
	public void startSession(String name, String password) throws Exception {
		this.name = name;
		this.password = password;
	}
 
	@Test
	public void testLoginValidCredential() throws Exception {
		login();
        assertEquals("Dashboard - management console - Cloud Services", getDriver().getTitle());
	}
	
	@Test
	public void testDashboardTotal() throws Exception {
		login();
		getDriver().findElement(By.cssSelector("#dashStatus div.total.clickable")).click();
		assertEquals("Virtual servers - management console - Cloud Services", getDriver().getTitle());
	}
	
	/**
	 * Login to PSL
	 */
	private void login() {
		getDriver().get(getBaseUrl());
		WebElement search =getDriver().findElement(By.name("uname"));
        search.sendKeys(name);
        search = getDriver().findElement(By.name("password"));
        search.sendKeys(password);
        getDriver().findElement(By.id("login_standard")).click();
	}
	
	

}
